package o;

import android.text.SpannableStringBuilder;
import android.text.StaticLayout;

public abstract class bsw {
    public static CharSequence ˎ(int i, StaticLayout staticLayout, SpannableStringBuilder spannableStringBuilder) {
        if (i <= 0) {
            return "";
        }
        int lineCount = staticLayout.getLineCount();
        if (lineCount <= 0) {
            return "";
        }
        if (i > lineCount) {
            i = lineCount;
        }
        return spannableStringBuilder.subSequence(0, staticLayout.getLineEnd(i - 1));
    }

    public static CharSequence ॱ(int i, StaticLayout staticLayout, SpannableStringBuilder spannableStringBuilder) {
        if (i <= 0) {
            return "";
        }
        int lineCount = staticLayout.getLineCount();
        if (lineCount <= 0) {
            return "";
        }
        int i2 = i - 1;
        if (i2 >= lineCount) {
            lineCount--;
        } else {
            lineCount = i2;
        }
        i2 = 0;
        if (lineCount - 1 >= 0) {
            try {
                i2 = staticLayout.getLineEnd(lineCount - 1);
            } catch (IndexOutOfBoundsException e) {
                bqx.ˋ("LineStringUtils", "getLineString error");
                return "";
            }
        }
        lineCount = staticLayout.getLineEnd(lineCount);
        if (lineCount - 1 < 0 || spannableStringBuilder.charAt(lineCount - 1) != '\n') {
            return spannableStringBuilder.subSequence(i2, lineCount);
        }
        return spannableStringBuilder.subSequence(i2, lineCount - 1);
    }
}
